home *** CD-ROM | disk | FTP | other *** search
- /* WARNING: THIS EXAMPLE IS QUICK & DIRTY!!! Its only purpose is to */
- /* demonstrate how certain MB_lib functions are used and how they work. */
- /* While the code is a functional program, no attempt has been made to */
- /* clean up the code or to streamline it, and I've economized a bit on */
- /* error checking since I've made this in a hurry. However, if you're */
- /* able to use MB_lib, odds are that you also know how to write neat code. */
-
- /* Scan mail to a certain user, first forward, then reverse */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "mb_lib.h"
-
- long recnr;
- MSGHDR_RECORD hdr;
- MSGTOIDX_RECORD to;
-
- main () {
- if (msg_open ("C:\\MSGBASE")) {
- puts ("Error opening message base");
- exit (1);
- }
- puts ("User name?");
- gets (to);
- puts ("Listing forward...");
- recnr = msg_firstto (& to);
- while (recnr != -1) {
- msg_read_hdr (recnr, & hdr); /* Ignore errors for the moment */
- printf ("Board: %3d Message: %6d\nBy: %s\nRe: %s\n\n", hdr.board,
- hdr.msgnum, hdr.who_from, hdr.subject);
- recnr = msg_nextto (recnr);
- }
- puts ("Listing reverse...");
- recnr = msg_lastto (& to);
- while (recnr != -1) {
- msg_read_hdr (recnr, & hdr); /* Ignore errors for the moment */
- printf ("Board: %3d Message: %6d\nBy: %s\nRe: %s\n\n", hdr.board,
- hdr.msgnum, hdr.who_from, hdr.subject);
- recnr = msg_prevto (recnr);
- }
- msg_close ();
- puts ("Done.");
- return (0);
- }